﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NCLCustomerManagement.BusinessLogic.History;
using NCLCustomerManagement.DataTransferObjects.History;
using NCLCustomerManagement.UI.Helper;
using NCLCustomerManagement.UI.Models;

namespace NCLCustomerManagement.UI.Controllers
{
    public class HistoryController : BaseController
    {
        //private IHistoryBC _histBC;

        public HistoryController(IBCFactory bcFactory)
        {
            //_histBC = bcFactory.GetBC<IHistoryBC>();
       
        }

        [AuthenticationRequired]
        public ActionResult GetHistoryList(int pageIndex = 0, int pageSize = 20, int type = 0)
        {
            IEnumerable<HistoryModel> list;
            if (type == 0)
            {
                list = HistoryBC.GetLoginHistoryList(pageIndex, pageSize)
                    .Select(e => ConvertDTOToModel<HistoryDTO, HistoryModel>(e));
            }
            else
            {
                list = HistoryBC.GetOtherOperationsHistoryList(pageIndex, pageSize)
                     .Select(e => ConvertDTOToModel<HistoryDTO, HistoryModel>(e));
            }
            return PartialView("_HistoryPartial", list.ToList() as object);

        }

        [AuthenticationRequired]
        public ActionResult ViewHistory(int id)
        {
            return View(id as object);
        }

        [AuthenticationRequired]
        public ActionResult Index()
        {
            return View();
        }

    }
}
